package com.iot.data;

import java.util.HashSet;
import java.util.Set;

/**
 * @author Cao.ning
 * @date 2023/4/15
 */
public class ClientData {

    private static Set<String> onlineQuakeClientSet = new HashSet<>();
    private static Set<String> onlineGasClientSet = new HashSet<>();

    private static Set<String> offlineQuakeClientSet = new HashSet<>();
    private static Set<String> offlineGasClientSet = new HashSet<>();

    public static void setOnlineQuakeClientSet(Set<String> onlineQuakeClientSet) {
        ClientData.onlineQuakeClientSet = onlineQuakeClientSet;
    }

    public static void setOnlineGasClientSet(Set<String> onlineGasClientSet) {
        ClientData.onlineGasClientSet = onlineGasClientSet;
    }

    public static Set<String> getOnlineQuakeClientSet() {
        return onlineQuakeClientSet;
    }

    public static Set<String> getOnlineGasClientSet() {
        return onlineGasClientSet;
    }

    public static Set<String> getOfflineQuakeClientSet() {
        return offlineQuakeClientSet;
    }

    public static void setOfflineQuakeClientSet(Set<String> offlineQuakeClientSet) {
        ClientData.offlineQuakeClientSet = offlineQuakeClientSet;
    }

    public static Set<String> getOfflineGasClientSet() {
        return offlineGasClientSet;
    }

    public static void setOfflineGasClientSet(Set<String> offlineGasClientSet) {
        ClientData.offlineGasClientSet = offlineGasClientSet;
    }

    /**
     * 地震设备上线
     * @param clientNo
     */
    public static void quakeClientOnline(String clientNo){
        onlineQuakeClientSet.add(clientNo);
        offlineQuakeClientSet.remove(clientNo);
    }

    /**
     * 地震设备离线
     * @param clientNo
     */
    public static void quakeClientOffline(String clientNo){
        onlineQuakeClientSet.remove(clientNo);
        offlineQuakeClientSet.add(clientNo);
    }

    /**
     * 燃气设备上线
     * @param clientNo
     */
    public static void gasClientOnline(String clientNo){
        onlineGasClientSet.add(clientNo);
        offlineGasClientSet.remove(clientNo);
    }

    /**
     * 燃气设备离线
     * @param clientNo
     */
    public static void gasClientOffline(String clientNo){
        onlineGasClientSet.remove(clientNo);
        offlineGasClientSet.add(clientNo);
    }

    public static boolean quakeClientIsOnline(String clientNo) {
        return onlineQuakeClientSet.contains(clientNo);
    }
}
